/**
 * @author bipul_sinha
 * @version 1.0
 * @created 26th November, 2010.
 *
 * ApplicationUtils
 *
 * Copyright @ 2010
 * All Rights Reserved.
 * CONFIDENTIAL AND TRADE SECRET
 */
package com.ces.knacky.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.ces.knacky.framework.exception.DataAccessException;

/**
 * Utility class of the application. Contains utility methods required for processing.
 * 
 * @author bipul_sinha
 *
 */
public class ApplicationUtils {
	
	/**
	 * Private constructor so that no object can be instantiated.
	 */
	private ApplicationUtils() {
		
	}
	/**
	 * Utility method to change string to date object. It takes dateText in the form of 'yyyy-MM-dd'
	 * format and returns a date object.
	 * 
	 * @param 	dateText
	 * 			Date in string format (yyyy-MM-ddd).
	 * @return	Date
	 * 			Returns date object of the parameterized string. 
	 * @throws 	DataAccessException
	 * 			When unable to parse dateText value into Date object.
	 */
	public static Date convertStringToDate(String dateText) throws DataAccessException {
		Date date	= null;
		DateFormat df = new SimpleDateFormat(CalendarEnum.YMD.getDateFormat());
		System.out.println("dateText = "+dateText);
		try {
			date = df.parse(dateText);
		} catch (ParseException parseException) {
			throw new DataAccessException(parseException);
		}
		return date;
	}
}
